#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>

char* longestCommonPrefix(char** strs, int strsSize) {
    int c=0;
    while( strs[0][c] ){
        int i;
        for( i=0; i<strsSize && strs[i][c]!='\0'; i++)
            if( strs[i][c] != strs[0][c] )
                break;
        if( i < strsSize ) break;
        c++;
    }
    char *ret=malloc(sizeof(char)*(c+1));
    for(int i=0; i<c; i++)
        ret[i]=strs[0][i];
    ret[c]='\0';
    return ret;
}


int main(){
    /*
    char a[]="flower";
    char b[]="flow";
    char c[]="flight";
    char a[]="dog";
    char b[]="racecar";
    char c[]="car";
    */
    char a[]="ab";
    char b[]="a";
    char* s[3]={a,b};
    printf("%s\n",longestCommonPrefix(s,2));
    return 0;
}
